home *** CD-ROM | disk | FTP | other *** search
/ The Essential Home & Business Collection / The Essential Home & Business Collection.iso / 27 / 3 / 5 / HP22D5.ZIP / EXTERN / TESTASM.ASM < prev    next >
Assembly Source File  |  1991-04-16  |  1KB  |  73 lines

  1. DOSSEG
  2. .MODEL        LARGE
  3.  
  4. include        extern.inc
  5.  
  6. extrn        _printf:far
  7.  
  8. .DATA
  9.  
  10. SampleName         db        'sample',0
  11.  
  12. Pool        PoolStruct    <SampleName,SampleProc,,HANDLER>
  13.         PoolStruct    <>    ;END
  14.  
  15. formatstr    db        '%s',13,10,0
  16.  
  17. .CODE
  18.  
  19. WhenLoaded    proc        far
  20.         ret
  21. WhenLoaded    endp
  22.  
  23. WhenUnLoaded    proc        far
  24.         ret
  25. WhenUnLoaded    endp
  26.  
  27. ;
  28. ; SampleProc: This routine prints out all of the arguments that
  29. ; you pass to it. It may mess up the screen, but this doesn't hurt
  30. ; anything. To call the handler from HyperPAD:
  31. ;
  32. ; handler select;
  33. ; begin
  34. ;   sample "hello","world",1,2,3;
  35. ; end;
  36. ;
  37. SampleProc    proc        far
  38.         push        bp
  39.         mov        bp,sp
  40.  
  41.         ;check number of arguments
  42.         mov        cx,[bp+6]    ;CX = NumArgs
  43.         jcxz        SP_END        ;exit if no args
  44.  
  45.         push        di        ;save DI, use as counter
  46.         mov        di,cx        ;DI = NumArgs
  47.  
  48.         add        bp,8        ;BP = next argument
  49.  
  50. SP_TOP:
  51.         les        bx,[bp]        ;ES:BX = hdl
  52.         les        bx,es:[bx]    ;ES:BX = *hdl
  53.         push        es
  54.         push        bx        ;pass pointer to string
  55.         push        ds        ;segment of format string
  56.         mov        ax,offset formatstr
  57.         push        ax        ;AX = offset of format string
  58.         call        _printf
  59.         add        sp,8        ;cleanup stack after C call
  60.  
  61.         add        bp,4
  62.         dec        di
  63.         jnz        SP_TOP        ;loop until no more args
  64.  
  65.         pop        di
  66. SP_END:
  67.         mov        ax,STOP        ;don't pass on
  68.         pop        bp
  69.         ret
  70. SampleProc    endp
  71.  
  72. END
  73.